#pragma once
#include <iostream>
#include <string>
#include <ostream>
#include <fstream>
#include <sstream>
#include <algorithm>
#include <vector>
#include <ctime>
#include <filesystem>
#include <set>
#include <map>
#include <Python.h>
#include <streambuf>

#include "GeneralMethod.h"

using namespace std;

#ifdef __cplusplus
extern "C" {
#endif
int ConvertModelData(std::string input_label,std::string input_file,std::string output_label,std::string output_path);

#ifdef __cplusplus
}
#endif

int main_function(int argc, std::vector<std::string> argv);

std::pair<bool, std::vector<std::string>> check_arguments(std::vector<std::string>& arguments,string& input_file_path, string&output_file_path, string& input_file_name);

// 自定义输出流类，用于同时输出到控制台和文件
class DualStream : public std::streambuf {
public:
	DualStream(std::streambuf* coutBuf, std::streambuf* fileBuf)
		: coutBuf_(coutBuf), fileBuf_(fileBuf) {}

protected:
	virtual int overflow(int c) {
		if (c != traits_type::eof()) {
			if (coutBuf_->sputc(c) == traits_type::eof()) {
				return traits_type::eof();
			}
			if (fileBuf_->sputc(c) == traits_type::eof()) {
				return traits_type::eof();
			}
		}
		return c;
	}

	virtual int sync() {
		if (coutBuf_->pubsync() == -1) {
			return -1;
		}
		if (fileBuf_->pubsync() == -1) {
			return -1;
		}
		return 0;
	}

private:
	std::streambuf* coutBuf_;
	std::streambuf* fileBuf_;
};